/**
 * GameEngineLayer.h
 * This class includes all the basic logics such as detecting touch and interpretting it, and 
 * then sets up a method to be called 60 times a second that runs the game logic. 
 * 
 * 
 * Revision History: 
 *
 * Date     Author       Version   Changes
 * ======== ============ ========= ================================================================
 * 05/08/09 PJ Cabrera   1.0       Initial version. 
 * 02/17/10 Steve Hu	 1.1	   Updated board column and row size to 6x9.
 * 02/22/10 Robin Mahony 1.2	   1. Updated naming of blocks (block1 -> currentBlock), declared 
 *									  nextBlock.
 *								   2. Declared new labels (levelNumberLabel, factorLabel, 
 *									  levelLabel.
 * 02/24/10 Robin Mahony 1.3	   Changed board size to 8 columns and 10 rows.
 * 03/03/10 Olive C.     1.4       Added sum1~8, oldSum1~8, x1, y1, factor, sumNumberLabel1~8, and 
 *								   multiple.
 * 03/06/10 Steve Hu	 1.5	   Combined sum variables with an single array for sum logic.
 * 03/12/10 Steve Hu     1.6       Removed unrelated variable such as Flip.
 * 03/15/10 Steve Hu     1.F       ************** End of the Version 1 Implementation *************
 *
 * 03/16/10 Robin Mahony 2.1       Added new touchtype, "kPause"
 * 03/18/10 Robin Mahony 2.2       Added new touchtype, "kGarbage", and new labels/variables for 
 *								   use with garbage feature.
 * 03/19/10 Steve Hu	 2.3	   Added new checking for filled row grouping, "filledGroupExist".
 * 03/20/10 Robin Mahony 2.4	   Added new int value baseScore for use with setting score 
 *								   benchmarks.
 * 03/21/10 Steve Hu	 2.5	   Define macro for top score website address.
 * 03/25/10 Judy Cheng   2.11      Added checkX for use with xBlock
 * ======== ============ ========= ================================================================
 *
 */

#import "Block.h"
#import <AVFoundation/AVFoundation.h>
#import "MenuScene.h"
#import "SaveScoreScene.h"


@interface GameEngineLayer : Layer 
{
	/* Define the different kinds of touch events for the GameEngine.  */
	enum touchTypes 
	{
		kNone, 
		kDropBlocks, 
		kMoveLeft, 
		kMoveRight,
		kPause,
		kGarbage
	} touchType;
	
#define kLastColumn 7
#define kLastRow 9
#define numOfSum 8
#define numOfList 5
	
	/* The board (block moving area) is set 8 columns wide x 10 rows tall.  */
	Block *board[kLastColumn + 1][kLastRow + 1];
	Block *CurrentBlock, *NextBlock; 
	
	int frameCount; /* The frameCount is incremented every frame.  */  
	int moveCycleRatio; /* The number of frames needed for a block to drop to the row below.  */
	int difficulty;
	int score;
	int x1; /* Block's x coordinate on the board.  */
	int y1; /* Block's y coordinate on the board.  */
	int factor;
	int sum[numOfSum];
	int oldSum[numOfSum];
	int numGarbages;
	int oldNumGarbages;
	int baseScore;
	int checkX[numOfSum];
	int lowestScore;
	int countgrouping;
	/* Different numerical labels as shown in the game.  */
	Label *sumNumberLabel[numOfSum];
	Label *scoreLabel;
	Label *levelNumberLabel;
	Label *levelLabel;
	Label *factorLabel;
	Label *garbageNumLabel;
	
	BOOL isMultiple; /* Flag to determine if all columns are multiple of the factor.  */
	BOOL filledGroupExist;
	BOOL soundStatus;
	BOOL userSave;
	BOOL lastRow;
	UITextField *userName;
	/* Collection objects provided by Cocoa which are used to detects group of adjacent blocks.  */
    NSMutableSet *currentGrouping;
	NSMutableSet *groupings;
	
	AVAudioPlayer *player;
	NSString *path;
	NSError *error;
}
@property (nonatomic, retain) AVAudioPlayer *player;
@property (retain) NSString *path;

- (void) updateBoard: (ccTime) dt;
@end


